package com.file_io;

import java.io.File;
import java.util.*;

public class FileKinds {
    public static void fileDir(File file) {
        Map<String, Integer> map = new HashMap<>();
        Map<String, Integer> map1 = new HashMap<>();
        int count = 0;
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File file1 : files) {
                if (file1.isFile()) {
                    int a = file1.getName().indexOf(".");
                    String kinds = file1.getName().substring(a + 1);
                    map.put(kinds, 0);
                    Set<String> set = map.keySet();
                    for (String k : set) {
                        for (File file2 : files) {
                            if (file1.isFile()) {
                                int b = file1.getName().indexOf(".");
                                String kinds1 = file1.getName().substring(a + 1);
                                if (kinds1.equalsIgnoreCase(kinds)) {
                                    count++;
                                    map1.put(kinds, count);
                                }

                            }
                        }

                    }
                } else {
                    fileDir(file);
                }
            }

        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入文件路径");
        String filePath = in.next();
        File file3 = new File(filePath);
    }
}